package main

import (
	"fmt"
	"time"
)

// 主协程 退出了，其他子协程也要跟着退出
func main() {

	go func() {
		i := 0
		for true {
			i++
			fmt.Println("sub ", i)
			time.Sleep(time.Second)
		}
	}()

	time.Sleep(time.Second)

	i := 0
	for true {
		i++
		fmt.Println("main ", i)
		time.Sleep(time.Second)
		if i == 2 {
			break
		}
	}
}
